package model;

/**
 * Code.java
 * Purpose: Represents a code in the system
 * 
 * @author Hans Brems
 * @version 1.0 31/05/2012
 */

import java.io.Serializable;
import javax.persistence.*;

@SuppressWarnings("serial")
@Entity
public class Code implements Serializable {
	/* Reference */
	@Id
	private String code;
	/* Description */
	private String description;
	/* Active */
	private boolean active;
	
	/* Type of code (for example status, priority, unit of measurement) */
	@ManyToOne
	@JoinColumn(name="codetype_id")
	private CodeType codeType;
	
	/** Returns the code */
	public String getCode() {
		return code;
	}
	
	/** Sets the code */
	public void setCode(String code) {
		this.code = code;
	}
	
	/** Returns the code type */
	public CodeType getCodeType() {
		return this.codeType;
	}
	
	/** Sets the code type */
	public void setCodeType (CodeType codeType) {
		this.codeType = codeType;
	}
	
	/** Returns the description */
	public String getDescription() {
		return description;
	}
	
	/** Sets the description */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/** Returns the active state */
	public boolean isActive() {
		return active;
	}
	
	/** Sets the active state */
	public void setActive(boolean active) {
		this.active = active;
	}
	
	@Override
	public String toString() {
		return this.description;
	}
}
